package Vista;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.Choice;
import java.awt.Font;
import javax.swing.JList;
import javax.swing.AbstractListModel;
import javax.swing.JTree;
import javax.swing.JLabel;
import com.jgoodies.forms.factories.DefaultComponentFactory;
import java.awt.ScrollPane;
import org.eclipse.wb.swing.FocusTraversalOnArray;
import java.awt.Component;
import javax.swing.JMenuBar;
import javax.swing.JPopupMenu;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.Color;
import javax.swing.JMenuItem;
import javax.swing.JMenu;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JSeparator;
import javax.swing.JSpinner;
import javax.swing.JFormattedTextField;
import javax.swing.JToggleButton;
import javax.swing.JComboBox;

public class P0002 extends JDialog {

	private final JPanel contentPanel = new JPanel();

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		try {
			P0002 dialog = new P0002();
			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Create the dialog.
	 */
	public P0002() {
		setBounds(100, 100, 450, 300);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setToolTipText("1\r\n2\r\n2\r\n");
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(null);
		
		JList list = new JList();
		list.setSelectedIndices(new int[] {4});
		list.setModel(new AbstractListModel() {
			String[] values = new String[] {"Altas", "Bajas", "Modificacion", "Consultas"};
			public int getSize() {
				return values.length;
			}
			public Object getElementAt(int index) {
				return values[index];
			}
		});
		list.setSelectedIndex(3);
		list.setBounds(319, 11, 65, 77);
		contentPanel.add(list);
		
		JMenu mnCursosm = new JMenu("cursosM");
		mnCursosm.setToolTipText("aa\r\nss\r\ndd\r\n");
		mnCursosm.setBounds(176, 22, 83, 19);
		contentPanel.add(mnCursosm);
		
		JRadioButtonMenuItem rdbtnmntmPrueba = new JRadioButtonMenuItem("prueba");
		rdbtnmntmPrueba.setVerifyInputWhenFocusTarget(false);
		rdbtnmntmPrueba.setSelected(true);
		rdbtnmntmPrueba.setInheritsPopupMenu(true);
		rdbtnmntmPrueba.setAlignmentX(Component.LEFT_ALIGNMENT);
		rdbtnmntmPrueba.setBounds(202, 99, 107, 19);
		contentPanel.add(rdbtnmntmPrueba);
		
		JSeparator separator = new JSeparator();
		separator.setBounds(32, 152, 46, 2);
		contentPanel.add(separator);
		
		JFormattedTextField formattedTextField = new JFormattedTextField();
		formattedTextField.setBounds(28, 146, 50, 20);
		contentPanel.add(formattedTextField);
		
		JToggleButton tglbtnLlll = new JToggleButton("llll");
		tglbtnLlll.setSelected(true);
		tglbtnLlll.setToolTipText("");
		tglbtnLlll.setBounds(116, 166, 121, 23);
		contentPanel.add(tglbtnLlll);
		
		JComboBox comboBox = new JComboBox();
		comboBox.setBounds(279, 166, 65, 48);
		contentPanel.add(comboBox);
		contentPanel.setFocusTraversalPolicy(new FocusTraversalOnArray(new Component[]{list}));
		{
			JPanel buttonPane = new JPanel();
			buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
			getContentPane().add(buttonPane, BorderLayout.SOUTH);
			{
				JButton okButton = new JButton("OK");
				okButton.setActionCommand("OK");
				buttonPane.add(okButton);
				getRootPane().setDefaultButton(okButton);
			}
			{
				JButton cancelButton = new JButton("Cancel");
				cancelButton.setActionCommand("Cancel");
				buttonPane.add(cancelButton);
			}
		}
		
		JMenuBar menuBar_1 = new JMenuBar();
		setJMenuBar(menuBar_1);
		
		JMenu mnCursos = new JMenu("Cursos2");
		menuBar_1.add(mnCursos);
		
		JMenuItem mntmCursos = new JMenuItem("Cursos");
		mnCursos.add(mntmCursos);
		
		JMenuItem mntmAbrir = new JMenuItem("Abrir");
		mnCursos.add(mntmAbrir);
		
		JRadioButtonMenuItem rdbtnmntmRadiobutton = new JRadioButtonMenuItem("radiobutton");
		rdbtnmntmRadiobutton.setSelected(true);
		mnCursos.add(rdbtnmntmRadiobutton);
		
		JCheckBoxMenuItem chckbxmntmCheckitem = new JCheckBoxMenuItem("checkItem");
		chckbxmntmCheckitem.setSelected(true);
		mnCursos.add(chckbxmntmCheckitem);
		
		JMenuItem mntmSalir = new JMenuItem("Salir");
		mnCursos.add(mntmSalir);
	}
	private static void addPopup(Component component, final JPopupMenu popup) {
		component.addMouseListener(new MouseAdapter() {
			public void mousePressed(MouseEvent e) {
				if (e.isPopupTrigger()) {
					showMenu(e);
				}
			}
			public void mouseReleased(MouseEvent e) {
				if (e.isPopupTrigger()) {
					showMenu(e);
				}
			}
			private void showMenu(MouseEvent e) {
				popup.show(e.getComponent(), e.getX(), e.getY());
			}
		});
	}
}
